import type { ConsultType } from '@/enums'
import type { ConsultIllness, PartialConsult } from '@/types/consult'
import { defineStore } from 'pinia'
import { ref } from 'vue'
export const useConsultStore = defineStore(
  'consult',
  () => {
    // 问诊信息
    const consult = ref<PartialConsult>({})
    const setType = (type: ConsultType) => {
      consult.value.type = type
    }
    const setIllnessType = (illnessType: 0 | 1) => {
      consult.value.illnessType = illnessType
    }
    const setDepId = (depId: string) => {
      consult.value.depId = depId
    }
    // 病情描述
    const setIllness = (illness: ConsultIllness) => {
      consult.value.illnessDesc = illness.illnessDesc
      consult.value.pictures = illness.pictures
      consult.value.illnessTime = illness.illnessTime
      consult.value.consultFlag = illness.consultFlag
    }
    // 记录患者
    const setPatient = (patientId: string) => {
      consult.value.patientId = patientId
    }
    // 优惠券
    const setCoupon = (couponId: string) => {
      consult.value.couponId = couponId
    }
    // 清除数据
    const clear = () => {
      consult.value = {}
    }
    return { consult, setType, setIllnessType, setDepId, setIllness, setPatient, setCoupon, clear }
  },
  {
    persist: true,
  },
)
